﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.Base;
using ERP_RORZE_DLL.Product.DAO;
using ERP_RORZE_DLL.Product.Base;
using ERP_RORZE_PERMISSION.Base;

namespace ERP_RORZE_PRODUCT.Product.WTS
{
    public partial class frm_LaborWTStoGA : DevExpress.XtraEditors.XtraForm
    {
        ClsWTSDAO clsWTSDAO = new ClsWTSDAO();

        DataTable dt;
        private LogUtils log;

        public frm_LaborWTStoGA()
        {
            InitializeComponent();
            log = new LogUtils();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            gridView1.Columns.Clear();
            clsWTSDAO.PWTSTOGAAPPEND(dateFrom.Value.Date, dateTo.Value.Date);

            dt = clsWTSDAO.GetAllLaborWTStoGA(dateFrom.Value.Date, dateTo.Value.Date);

            //write Log
            log.Table = LogConstant.Table.Product.WTStoGALabor;
            log.Task = LogConstant.Task.View;
            log.Description = "View WTStoGA Labor from " + dateFrom.Value.Date.ToShortDateString() + " to " + dateTo.Value.Date.ToShortDateString();
            log.WriteLog();

            gridControl1.DataSource = dt;
            gridView1.BestFitColumns();
            gridView1.ViewCaption = "Labor WTS Data to GA";
            Cursor.Current = Cursors.Default;
        }

        private void btExport_Click(object sender, EventArgs e)
        {
            clsConstantsFuction.ExportToExcel(gridView1, 1, true);
        }

        private void btWtsDensan_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtMonthlyOrder.Text))
            {
                Cursor.Current = Cursors.WaitCursor;
                gridView1.Columns.Clear();
                clsWTSDAO.PWTSTOGAAPPEND(dateFrom.Value.Date, dateTo.Value.Date);

                dt = clsWTSDAO.GetAllWTSDensan(dateFrom.Value.Date, dateTo.Value.Date, txtMonthlyOrder.Text);

                //write Log
                log.Table = LogConstant.Table.Product.WTSDensan;
                log.Task = LogConstant.Task.View;
                log.Description = "View WTS Densan from " + dateFrom.Value.Date.ToShortDateString() + " to " + dateTo.Value.Date.ToShortDateString();
                log.WriteLog();

                gridControl1.DataSource = dt;
                gridView1.BestFitColumns();
                gridView1.ViewCaption = "WTS TO DENSAN";
                Cursor.Current = Cursors.Default;
            }
            else
            {
                MessageBox.Show("Bạn phải nhập Order tháng.");
            }

        }

    }
}